﻿<?php
/**
 * Hello View for Hello World Component
 * 
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://dev.joomla.org/component/option,com_jd-wiki/Itemid,31/id,tutorials:components/
 * @license		GNU/GPL
 */

jimport( 'joomla.application.component.view');

/**
 * HTML View class for the HelloWorld Component
 *
 * @package		Joomla.Tutorials
 * @subpackage	Components
 */
class DeTaiViewDeTai extends JView
{

	function display($tpl = null)
	{
        JToolBarHelper::title( JText::_( 'Quản lý danh sách đề tài' ), 'generic.png' ); 
        JToolBarHelper::deleteList(); 
        JToolBarHelper::editListX(); 
        JToolBarHelper::addNewX(); 
        // Get data from the model 
		// Get data from the model 
        $items =& $this->get( 'Data'); 
		$pagination =& $this->get('Pagination');
		
        
		/* Call the state object */
		$state =& $this->get( 'state' );
 
		/* Get the values from the state object that were inserted in the model's construct function */
		$lists['order_Dir'] = $state->get( 'filter_order_Dir' );
		$lists['order']     = $state->get( 'filter_order' );
		/* Call the state object */
		$state =& $this->get( 'state' );
 
		/* Get the values from the state object that were inserted in the model's construct function */
		$lists['order_Dir'] = $state->get( 'filter_order_Dir' );
		$lists['order']     = $state->get( 'filter_order' );        $items =& $this->get( 'AllData'); 
		/*Create list of nganh*/	
		$filter_nganh= $state->get('filter_nganh');	 
			
		$db	=& JFactory::getDBO();
		$query = 'SELECT manganh AS value, tennganh AS text'
			. ' FROM #__nganh'
		;
		$db->setQuery( $query );
		$types[] = JHTML::_('select.option',  '', '- '. JText::_( 'Chọn ngành' ) .' -' );
		foreach( $db->loadObjectList() as $obj )
		{
			$types[] = JHTML::_('select.option',  $obj->value, JText::_( $obj->text ) );
		}
		$lists['type'] 	= JHTML::_('select.genericlist',   $types, 'filter_nganh', 'class="inputbox" size="1" 
		onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_nganh" );
		/* End */	
		
		/*Create list of phan nganh*/
		$filter_chuyennganh=$state->get('filter_chuyennganh');
		
		$where='';
		if($filter_nganh!='')
			$where='where manganh=\''.$filter_nganh.'\'';
		$query = 'SELECT *'
			. ' FROM #__phan_nganh '.$where;
		;
		$db->setQuery( $query );
		$type2[] = JHTML::_('select.option',  '', '- '. JText::_( 'Chọn chyên ngành' ) .' -' );
		foreach( $db->loadObjectList() as $obj )
		{
			$type2[] = JHTML::_('select.option',  $obj->tenphannganh, JText::_( $obj->tenphannganh ) );
		}
		$lists['chuyennganh'] 	= JHTML::_('select.genericlist',   $type2, 'filter_chuyennganh', 'class="inputbox" size="1" style="margin-left:5px"
		onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_chuyennganh" );
		
		/* End */
        $items =& $this->get( 'AllData'); 
        $this->assignRef( 'items', $items );
		$this->assignRef('pagination', $pagination);
		$this->assignRef('lists',$lists);		
			parent::display($tpl); 
		} 
}
?>